-
Notifications
You must be signed in to change notification settings - Fork 168
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
virttools: add new test type and virt-install test #3923
Conversation
Test run
|
Regression coverage for changes in
|
f881c2a
to
06e1994
Compare
@dzhengfy @chunfuwen @Yingshun Please, can you help review? |
31031c7
to
73a563f
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Others LGTM
raise NotImplementedError() | ||
|
||
@staticmethod | ||
def from_type(mdev_type): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the function name is not very meaningful and explicit. Could we use one similar like 'get_instance_from_type()'?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@dzhengfy I would like to maintain it, IMO, it's a common python idiom, please check https://github.com/avocado-framework/avocado-vt/pull/2610/files#r445400984
ccw.set_device_offline(self.device_id) | ||
|
||
|
||
def disk_for_import(vmxml): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To align the naming style for functions in your codes, I suggest we name this function beginning with a verb, like 'get_disk_for_import()'. But the decision depends on you.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I updated it.
return first_disk.find('source').get('file') | ||
|
||
|
||
def first_mdev_nodedev_name(): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
get_first_mdev_nodedev_name()?
But this decision depends on you
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I updated it.
|
||
session = vm.wait_for_login() | ||
handler.check_device_present_inside_guest(session) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is better to close the session.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The session is closed now in the final clause handler.clean_up
.
raise TestError("Test doesn't know how to handle %s." % mdev_type) | ||
|
||
|
||
class CcwMdevHandler(MdevHandler): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How about moving CcwMdevHandler and MdevHandler to provider? I wonder if they can be used by other tests...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Yingshun At this point the base class doesn't do anything but only serves as interface to be implemented. Especially the get_target_address
method at this point to me looks rather test specific. I'm not sure if somebody found those classes below the provider path they would know what to do with them without the context of the test implementation. Therefore, I'd like to wait for other tests to need these classes before moving them. Is that okay?
:raises: TestFail if device not found | ||
""" | ||
device, _ = ccw.get_first_device_identifiers(self.chpids, session) | ||
if not device == self.expected_device_address: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would suggest using inline negation, please refer to https://www.python.org/dev/peps/pep-0008/#programming-recommendations(Use is not operator rather than not ... is. While both expressions are functionally identical, the former is more readable and preferred:...).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done :)
|
||
virt_install_with_hostdev(vm_name, mdev_nodedev, target_address, disk) | ||
|
||
session = vm.wait_for_login() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you need to start the vm before trying to loin?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you need to start the vm before trying to loin?
No, the virt-install command boots the guest.
8249f0d
to
dfa4178
Compare
from virttest import virsh | ||
|
||
|
||
class MdevHandler(object): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just curious that in terms of MdevHandler, would you like maintain it as local test module in hostdev_mdev.py , or it could be more generic module shared across test modules?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@chunfuwen I think your question is covered in discussion above #3923 (comment)
@@ -0,0 +1,198 @@ | |||
import logging |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please add 'LOG = log.getLogger('avocado.' + name)' and replace logging.xxx with LOG.xxx in the code. The current way does not log messages in the latest avocado. For details, please check #3833
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done :)
dfa4178
to
0dcd75d
Compare
Rerun after requested changes:
|
0dcd75d
to
3d05e37
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Others LGTM
provider/vfio/ccw.py
Outdated
|
||
:param device_id: cssid.ssid.devno, e.g. 0.0.560a | ||
:param session: guest session, command is run on host if None | ||
:raises TestError: if the device can't be set online |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should 'online' be 'offline'?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, there's already a function set_device_online
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry @smitterl ,I should speak full sentence to make the comment clearer.
This function is set_device_offline() which used to set the device offline. And from the code, we can see that it'll raise TestError if the device can't be set offline, but not online. So I mean, I think it's a typo here, and it should be like:
:raises TestError: if the device can't be set online | |
:raises TestError: if the device can't be set offline |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Got it now @Yingshun You are right. I fixed it. Thank you!
1. /virttools: Add new test type for tools from virt-manager repository; by using avocado-vt we get access to many useful test functions ready to use for qemu/libvirt testing. The test type assumes the same default setup as for tp-libvirt/libvirt and builds on top of that. During testing, switching from a bootstrapped libvirt environment to a bootstrapped virttools environment worked and the test case passed. 2. hostdev_mdev: Add a new test case. a. 'run': This virt-install test case is currently ccw device specific but other types on other platforms can be implemented by creating a subclass for the MdevHandler for the desired mdev_type. b. 'clean_up/sleep': The introduction of 1sec sleep is necessary to make sure setting the device offline will work. Using the usual 'wait_for' here seemed to overcomplicate the code. c. 'virt_install_with_hostdev': The function hardcodes several vm installation parameters. This is to keep the code simple at this point but can be changed in the future. 3. spell.ignore: Add command and device names used in ccw.py and hostdev_mdev.py. 4. ccw.py: Add a new function to set devices offline to reset them to their previous state. Test cases with real ccw devices usually assume the test environment is configured in a way that the first unused ccw device will be used for the test case, possibly in a destructive way. Some functions have been added return value 'True' on success to allow for usage in 'wait_for' constructions. 5. README.md: Add readme file to give a bit more context and intention for the new test type. Signed-off-by: Sebastian Mitterle <[email protected]>
3d05e37
to
3532df3
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
comments had been addressed, let's merge it |
Depends on avocado-vt PR avocado-framework/avocado-vt#3270
Add new test type for tools from virt-manager repository; by
using avocado-vt we get access to many useful test functions
ready to use for qemu/libvirt testing. The test type assumes
the same default setup as for tp-libvirt/libvirt and builds
on top of that. During testing, switching from a bootstrapped
libvirt environment to a bootstrapped virttools environment
worked and the test case passed.
Add a new test case.
a. 'run': This virt-install test case is currently ccw device
specific but other types on other platforms can be
implemented by creating a subclass for the
MdevHandler for the desired mdev_type.
b. 'clean_up/sleep': The introduction of 1sec sleep is
necessary to make sure setting the device offline will
work. Using the usual 'wait_for' here seemed to
overcomplicate the code.
c. 'virt_install_with_hostdev': The function hardcodes several
vm installation parameters. This is to keep the code
simple at this point but can be changed in the future.
Add command and device names used in ccw.py and hostdev_mdev.py.
Add a new function to set devices offline to reset them to their
previous state. Test cases with real ccw devices usually assume
the test environment is configured in a way that the first unused
ccw device will be used for the test case, possibly in a
destructive way. Some functions have been added return value 'True'
on success to allow for usage in 'wait_for' constructions.
Add readme file to give a bit more context and intention for the
new test type.
Signed-off-by: Sebastian Mitterle [email protected]